<?php

namespace Home\Controller;

use Think\Controller;

class DetailsController extends Controller
{
    public function Details()
    {

        //  查询导航部分的分类

        $model_sort = D('sort');
        $sorts = $model_sort->query("SELECT * FROM sort");
        $this->assign('sorts', $sorts);

         // 获取商品id

        $id = $_GET['id'];

        // 查询商品详细

        $model_goods = D('goods');
        $sql = sprintf("SELECT * FROM goods WHERE id ='%s'",$id);
        $good_es = $model_goods->query($sql);
        $this->assign('good_es', $good_es);


        // 当前商品属于的类名

        $sort_id = $good_es[0]['goods_sort'];
        $sql = sprintf("SELECT * FROM sort WHERE id = '%s'",$sort_id);
        $sor = $model_sort->query($sql);
        $this->assign('sor', $sor);

        
        //  四周商品

        $good = $model_goods->query("SELECT * FROM goods");
        $this->assign('good', $good);


        //  友情链接

        $model_link = D('link');
        $links = $model_link->query("SELECT * FROM link");
        $this->assign('links', $links);

        $this->display();
    }

}